package com.opo5.logisticsmanagement.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.mysql.cj.util.StringUtils;
import com.opo5.logisticsmanagement.Vo.*;
import com.opo5.logisticsmanagement.common.R;
import com.opo5.logisticsmanagement.dao.MaterialDao;
import com.opo5.logisticsmanagement.dao.UserDao;
import com.opo5.logisticsmanagement.domain.PlanList;
import com.opo5.logisticsmanagement.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("statis")
public class StatisController {
    //出车统计
    @Autowired
    VehicleListService vehicleListService;
    @GetMapping("/car/{page}/{pagesize}/{year}")
    public R car(@PathVariable int page,@PathVariable int pageSize,@PathVariable String year){
        R r=vehicleListService.statisCar(page,pageSize,year);
        return r;
    }
    //变电统计
    @Autowired
    PlanListService planListService;
    @GetMapping("/electricity/{page}/{pagesize}/{wastedescribe}")
    public R<Page> electricity(@PathVariable int page, @PathVariable int pagesize, @PathVariable String wastedescribe){
        Page<MaterialVo>iPage=new Page<MaterialVo>(page,pagesize);
        LambdaQueryWrapper<PlanList> queryWrapper=new LambdaQueryWrapper();
        if (wastedescribe !=null){
        queryWrapper.like(PlanList::getWastedescribe,wastedescribe);
        }
        return R.success(planListService.getPageVo(iPage));
    }
    //导线统计
    @Autowired
    SparePlanService sparePlanService;
    @GetMapping("/spare/{page}/{pagesize}/{materialdescribe}")
    public R<Page> spared(@PathVariable int page, @PathVariable int pagesize, @PathVariable String materialdescribe){
        Page<SpareVo>iPage=new Page<SpareVo>(page,pagesize);
        LambdaQueryWrapper<PlanList> queryWrapper=new LambdaQueryWrapper();
        if (materialdescribe !=null){
            queryWrapper.like(PlanList::getWastedescribe,materialdescribe);
        }
        return R.success(sparePlanService.getPageVo(iPage));
    }
    //新品统计
    @Autowired
    NewService newService;
    @GetMapping("/new/{page}/{pagesize}/{materialdescribe}")
    public R<Page> newpro(@PathVariable int page, @PathVariable int pagesize, @PathVariable String materialdescribe){
        Page<NewVo>iPage=new Page<NewVo>(page,pagesize);
        LambdaQueryWrapper<PlanList> queryWrapper=new LambdaQueryWrapper();
        if (materialdescribe !=null){
            queryWrapper.like(PlanList::getWastedescribe,materialdescribe);
        }
        return R.success(newService.getPageVo(iPage));}
    //电缆统计
    @Autowired
    CablePlanService cablePlanService;
    @GetMapping("/new1/{page}/{pagesize}")
    public R<Page> cable(@PathVariable int page, @PathVariable int pagesize){
        Page<CableVo>iPage=new Page<CableVo>(page,pagesize);
        LambdaQueryWrapper<PlanList> queryWrapper=new LambdaQueryWrapper();

        return R.success(cablePlanService.getPageVo(iPage));}
    //物料出入统计
    @Autowired
    MaterialService materialService;
    @GetMapping("/new/{page}/{pagesize}")
    public R<Page> materical(@PathVariable int page, @PathVariable int pagesize){
        Page<CableVo>iPage=new Page<CableVo>(page,pagesize);
        LambdaQueryWrapper<CableVo> queryWrapper=new LambdaQueryWrapper();

        return R.success(materialService.getPageVo(iPage));}
    //人员任务统计
    @Autowired
    UserService userService;
    @GetMapping("/new/{page}/{pagesize}/{year}")
    public R statisUser(@PathVariable int page, @PathVariable int pagesize,@PathVariable int year){
        Page<StatisUserVo>iPage=new Page<StatisUserVo>(page,pagesize);
        LambdaQueryWrapper<StatisVo> queryWrapper=new LambdaQueryWrapper();

        return R.success(userService.statisUser(iPage,year));}


}
